﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RoadTeam.Pase.FM;
using System.Xml;
using System.Web.Services.Protocols;
using System.ServiceModel;
using RoadTeam.BLL;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    /// <summary>
    /// 异常类型
    /// </summary>
    public enum FaultCode
    {
        Client = 0,
        Server = 1
    }

    public SoapException RaiseException(string uri, string errorMessage, string errorNumber, string errorSource, FaultCode code, System.Exception exception, String Parameter)
    {
        //初始化限定名
        XmlQualifiedName faultCodeLocation = null;

        //异常类型代码转换
        switch (code)
        {
            case FaultCode.Client:
                faultCodeLocation = SoapException.ClientFaultCode;
                break;
            case FaultCode.Server:
                faultCodeLocation = SoapException.ServerFaultCode;
                break;
        }

        //构建异常信息结构体
        string strXmlOut = @"<detail>"
                         + "<Error>"
                         + "<ErrorNumber>" + errorNumber + "</ErrorNumber>"
                         + "<ErrorMessage>" + errorMessage + "</ErrorMessage>"
                         + "<ErrorSource>" + errorSource + "</ErrorSource>"
                         + "</Error>"
                         + "</detail>";

        //装载为Xml文档
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(strXmlOut);

        //实例化SoapException
        SoapException soapEx = new SoapException(errorMessage, faultCodeLocation, uri, xmlDoc.DocumentElement);

        RoadTeam.Model.SmException EX = new RoadTeam.Model.SmException();
        EX.ExceptionMsg = exception.Message;
        EX.ExceptionStackTrace = exception.StackTrace.Replace(" 在", "<br/>在");

        EX.TargetSiteName = exception.TargetSite.Name;
        EX.TargetSiteFullName = exception.TargetSite.DeclaringType.FullName;
        EX.ExceptionSource = exception.Source;

        EX.MethodName = uri;
        EX.Parameter = Parameter;

        RoadTeam.BLL.SmExceptionBll bll = new RoadTeam.BLL.SmExceptionBll();
        bll.InSertException(EX);

        //返回SoapException
        return soapEx;
    }





    protected void Button1_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(Type.Text)) return;
        if (String.IsNullOrEmpty(data.Text)) return;

        try
        {
            switch (Type.Text)
            {
                case "MeterDegree":
                       BllBase bllbase = new BllBase();
                       bllbase.InsertLog(@"方法名[UpdateMeterDegreeCountCrossDoMain]调用时间[" + DateTime.Now.ToString() + "] 参数为:[" + data.Text + "]",@"asd","");
                     Response.Write(MeterDegreePase.UpdateMeterDegree(data.Text).ToString());

                    break;
                default:
                    break;
            }
        }
        catch (Exception ex)
        {
            throw ex;
             //RaiseException("UpdateMeterDegree", ex.Message, "1000", ex.Source, FaultCode.Server, ex, "Json:" + data.Text);
        }





    }
}